﻿<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Common="using:Coding4Fun.Toolkit.Test.WindowsStore.Common"
    xmlns:converters="using:Coding4Fun.Toolkit.Controls.Converters"
    xmlns:local="using:Coding4Fun.Toolkit.Test.WindowsStore">

    <converters:ThemedImageConverter x:Key="c4fThemedImageConverter" />
    <converters:ThicknessToGridLengthConverter x:Key="c4fThicknessConverter" />

    <Style TargetType="local:ThicknessToGridLengthConverterControl">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ThicknessToGridLengthConverterControl">
                    <Grid Margin="10" Background="Green">
                        <Grid.RowDefinitions>
                            <RowDefinition x:Name="topRow" Height="{Binding Padding, Converter={StaticResource c4fThicknessConverter}, ConverterParameter=Top, RelativeSource={RelativeSource TemplatedParent}}" />
                            <RowDefinition  />
                            <RowDefinition  x:Name="bottomRow"  Height="{Binding Padding, Converter={StaticResource c4fThicknessConverter}, ConverterParameter=Bottom, RelativeSource={RelativeSource TemplatedParent}}" />

                        </Grid.RowDefinitions>
                        <Rectangle Fill="Red" Grid.Row="0" />
                        <Rectangle Fill="Blue" Grid.Row="2" />
                        <TextBlock 
							Padding="{TemplateBinding Padding}"
							Grid.Row="1"
                            TextWrapping="Wrap">
							    Testing margin
                        </TextBlock>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="Common:BaseHeader">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="Common:BaseHeader">
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="Auto"/>
							<ColumnDefinition Width="*"/>
						</Grid.ColumnDefinitions>
						<Button 
							x:Name="backButton" 
							Style="{StaticResource BackButtonStyle}"/>
						<StackPanel Grid.Column="1" Margin="0, 0, 0, 40" VerticalAlignment="Bottom">
							<TextBlock 
								x:Name="appTitle" 
								Text="{StaticResource AppName}" 
								Style="{StaticResource PageHeaderTextStyle}" 
								FontSize="20" 
								Margin="2, 0, 0, 5"
								Visibility="{TemplateBinding ApplicationTitleVisibility}" />
							<TextBlock 
								x:Name="pageTitle" 
								Text="{TemplateBinding Title}" 
								Style="{StaticResource PageHeaderTextStyle}" 
								Margin="0"/>
							<VisualStateManager.VisualStateGroups>

								<!-- Visual states reflect the application's view state -->
								<VisualStateGroup x:Name="ApplicationViewStates">
									<VisualState x:Name="FullScreenLandscape"/>
									<VisualState x:Name="Filled"/>

									<!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
									<VisualState x:Name="FullScreenPortrait">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>

									<!-- The back button and title have different styles when snapped -->
									<VisualState x:Name="Snapped">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
							</VisualStateManager.VisualStateGroups>
						</StackPanel>
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>